Fluent动网格【3】:DEFINE

您所在的位置:网站首页 udf value什么意思 Fluent动网格【3】:DEFINE

Fluent动网格【3】:DEFINE

2023-12-18 17:01| 来源: 网络整理| 查看: 265

除了利用Profile进行运动指定之外,Fluent中还可以使用UDF宏来指定部件的运动。其中用于运动指定的宏主要有三个:

DEFINE_CG_MOTION DEFINE_GEOM DEFINE_GRID_MOTION

今天主要看第一个UDF宏DEFINE_CG_MOTION。

用途

DEFINE_CG_MOTION宏主要用于描述刚体的运动。所谓“刚体”,指的是在运动过程中部件几何形状不会发生任何改变,只是其质心位置发生改变。

在定义刚体的运动时,通常以速度方式进行显式定义。

形式

DEFINE_CG_MOTION宏的结构很简单。

DEFINE_CG_MOTION(name,dt,vel,omega,time,dtime)

其中:

name:为宏的名称,可以随意定义

dt:一个指针Dynamic_Thread *dt,存储动网格属性,通常不需要用户干预。

vel:平动速度,为一个数组,其中vel[0]为x方向速度,vel[1]为y方向速度,vel[2]为z方向速度。

omega:转动速度,omega[0]为x方向角速度,omega[1]为y方向角速度,omega[2]为z方向角速度。

time:当前时间。

dtime:时间步长。

DEFINE_CG_MOTION宏实际上是要返回数据vel或omega。__

实例

实例1:利用DEFINE_CG_MOTION宏定义速度:

\[u_x = 2 sin(3t) \]

可以写成:

#include "udf.h" DEFINE_CG_MOTION(velocity,dt,vel,omega,time,dtime) { vel[0] = 2* sin(3*time); }

很简单,对不对?

再来个复杂点的例子。

实例2:已知作用在部件上的力F,计算部件在力F作用下的运动。

可以采用牛顿第二定律:

\[\int_{t_0}^{t}{dv}=\int_{t_0}^{t}{(F/m)}dt \]

则速度可写为:

\[v_t = v_{t-\Delta t}+(F/m)\Delta t \]

可写UDF宏为:

/************************************************************ * 1-degree of freedom equation of motion (x-direction) * compiled UDF ************************************************************/ #include "udf.h" static real v_prev = 0.0; static real time_prev = 0.0; DEFINE_CG_MOTION(piston,dt,vel,omega,time,dtime) { Thread *t; face_t f; real NV_VEC(A); real force_x, dv; /* reset velocities */ NV_S(vel, =, 0.0); NV_S(omega, =, 0.0); if (!Data_Valid_P()) return; /* get the thread pointer for which this motion is defined */ t = DT_THREAD(dt); /* compute pressure force on body by looping through all faces */ force_x = 0.0; begin_f_loop(f,t) { F_AREA(A,f,t); force_x += F_P(f,t) * A[0]; } end_f_loop(f,t) /* compute change in velocity, dv = F*dt/mass */ dv = dtime * force_x / 50.0; /* motion UDFs can be called multiple times and should not cause false velocity updates */ if (time > (time_prev + EPSILON)) { v_prev += dv; time_prev = time; } Message("time = %f, x_vel = %f, x_force = %f\n", time, v_prev, force_x); /* set x-component of velocity */ vel[0] = v_prev; }


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3